
// pages/components/pop-up-noani/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    title: {
      type: 'String',
      value: ''
    },
    type: {
      type: 'String',
      value: ''
    },
    show: {
      type: Boolean,
      value: false
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    list: [{
        name: '余额支付',
        type: 'balancepay',
        img: '/pages/images/type-6.png',
        checked:false,
      },
      {
        name: '微信支付',
        type: 'wechatpay',
        img: '/pages/images/type-5.png',
        checked:false,
      },
    ]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    hideShareWindow() {
      this.triggerEvent('close')
    },
    clickTab(e) {
      let item = e.currentTarget.dataset.item
      let index = e.currentTarget.dataset.index
      let list = this.data.list
      item.checked = !item.checked
      
      list.forEach(function (obj, i) {
        if (i != index) {
          obj.checked = false
        }
      })
      list[index] = Object.assign(list[index],item)
      this.setData({
        list
      })
    },
    sure() {
      this.hideShareWindow()
      let str = this.data.list.find(el=>el.checked).type
      this.triggerEvent('sure',str)
    }
  }
})